<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>Database - GIAnT API</title>
    <link rel="stylesheet" href="http://yui.yahooapis.com/3.9.1/build/cssgrids/cssgrids-min.css">
    <link rel="stylesheet" href="../assets/vendor/prettify/prettify-min.css">
    <link rel="stylesheet" href="../assets/css/main.css" id="site_styles">
    <link rel="icon" href="../assets/favicon.ico">
    <script src="http://yui.yahooapis.com/combo?3.9.1/build/yui/yui-min.js"></script>
</head>
<body class="yui3-skin-sam">

<div id="doc">
    <div id="hd" class="yui3-g header">
        <div class="yui3-u-3-4">
                <h1><img src="../assets/css/logo.png" title="GIAnT API" width="117" height="52"></h1>
        </div>
        <div class="yui3-u-1-4 version">
            <em>API Docs for: 1.0.0</em>
        </div>
    </div>
    <div id="bd" class="yui3-g">

        <div class="yui3-u-1-4">
            <div id="docs-sidebar" class="sidebar apidocs">
                <div id="api-list">
                    <h2 class="off-left">APIs</h2>
                    <div id="api-tabview" class="tabview">
                        <ul class="tabs">
                            <li><a href="#api-classes">Classes</a></li>
                            <li><a href="#api-modules">Modules</a></li>
                        </ul>
                
                        <div id="api-tabview-filter">
                            <input type="search" id="api-filter" placeholder="Type to filter APIs">
                        </div>
                
                        <div id="api-tabview-panel">
                            <ul id="api-classes" class="apis classes">
                                <li><a href="../classes/Atom.html">Atom</a></li>
                                <li><a href="../classes/Codec.html">Codec</a></li>
                                <li><a href="../classes/Constraints.html">Constraints</a></li>
                                <li><a href="../classes/Database.html">Database</a></li>
                                <li><a href="../classes/Exif.html">Exif</a></li>
                                <li><a href="../classes/Export.html">Export</a></li>
                                <li><a href="../classes/Heatmap.html">Heatmap</a></li>
                                <li><a href="../classes/Server.html">Server</a></li>
                                <li><a href="../classes/Settings.html">Settings</a></li>
                                <li><a href="../classes/Utils.html">Utils</a></li>
                            </ul>
                
                
                            <ul id="api-modules" class="apis modules">
                            </ul>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="yui3-u-3-4">
                <div id="api-options">
                    Show:
                    <label for="api-show-inherited">
                        <input type="checkbox" id="api-show-inherited" checked>
                        Inherited
                    </label>
            
                    <label for="api-show-protected">
                        <input type="checkbox" id="api-show-protected">
                        Protected
                    </label>
            
                    <label for="api-show-private">
                        <input type="checkbox" id="api-show-private">
                        Private
                    </label>
                    <label for="api-show-deprecated">
                        <input type="checkbox" id="api-show-deprecated">
                        Deprecated
                    </label>
            
                </div>
            
            <div class="apidocs">
                <div id="docs-main">
                    <div class="content">
<h1>Database Class</h1>
<div class="box meta">


        <div class="foundat">
            Defined in: <a href="../files/src_database.js.html#l17"><code>src\database.js:17</code></a>
        </div>


</div>


<div class="box intro">
    <h2>Database</h2>
<p>Contains all the database access methods.</p>

</div>


<div id="classdocs" class="tabview">
    <ul class="api-class-tabs">
        <li class="api-class-tab index"><a href="#index">Index</a></li>

            <li class="api-class-tab methods"><a href="#methods">Methods</a></li>
            <li class="api-class-tab properties"><a href="#properties">Properties</a></li>
    </ul>

    <div>
        <div id="index" class="api-class-tabpanel index">
            <h2 class="off-left">Item Index</h2>

                <div class="index-section methods">
                    <h3>Methods</h3>

                    <ul class="index-list methods">
                            <li class="index-item method private">
                                <a href="#method__get_driver">_get_driver</a>

                            </li>
                            <li class="index-item method private">
                                <a href="#method__get_session">_get_session</a>

                            </li>
                            <li class="index-item method">
                                <a href="#method__hygiene">_hygiene</a>

                            </li>
                            <li class="index-item method private">
                                <a href="#method__remove_constraints">_remove_constraints</a>

                            </li>
                            <li class="index-item method">
                                <a href="#method_add_comment_to_fragment">add_comment_to_fragment</a>

                            </li>
                            <li class="index-item method">
                                <a href="#method_add_constraints">add_constraints</a>

                            </li>
                            <li class="index-item method">
                                <a href="#method_add_edge">add_edge</a>

                            </li>
                            <li class="index-item method">
                                <a href="#method_add_edge">add_edge</a>

                            </li>
                            <li class="index-item method">
                                <a href="#method_add_fragment">add_fragment</a>

                            </li>
                            <li class="index-item method">
                                <a href="#method_add_image">add_image</a>

                            </li>
                            <li class="index-item method">
                                <a href="#method_add_node">add_node</a>

                            </li>
                            <li class="index-item method">
                                <a href="#method_get_all_completed_fragments">get_all_completed_fragments</a>

                            </li>
                            <li class="index-item method">
                                <a href="#method_get_all_fragments">get_all_fragments</a>

                            </li>
                            <li class="index-item method">
                                <a href="#method_get_all_images">get_all_images</a>

                            </li>
                            <li class="index-item method">
                                <a href="#method_get_all_property_keys_for_token">get_all_property_keys_for_token</a>

                            </li>
                            <li class="index-item method">
                                <a href="#method_get_all_property_values_for_token">get_all_property_values_for_token</a>

                            </li>
                            <li class="index-item method">
                                <a href="#method_get_fragment">get_fragment</a>

                            </li>
                            <li class="index-item method">
                                <a href="#method_get_fragment_bounding_box">get_fragment_bounding_box</a>

                            </li>
                            <li class="index-item method">
                                <a href="#method_get_fragment_by_id">get_fragment_by_id</a>

                            </li>
                            <li class="index-item method">
                                <a href="#method_get_fragments_by_image_id">get_fragments_by_image_id</a>

                            </li>
                            <li class="index-item method">
                                <a href="#method_get_image">get_image</a>

                            </li>
                            <li class="index-item method">
                                <a href="#method_get_image_of_token">get_image_of_token</a>

                            </li>
                            <li class="index-item method">
                                <a href="#method_init">init</a>

                            </li>
                            <li class="index-item method">
                                <a href="#method_log_error_and_close_session">log_error_and_close_session</a>

                            </li>
                            <li class="index-item method">
                                <a href="#method_login">login</a>

                            </li>
                            <li class="index-item method">
                                <a href="#method_logout">logout</a>

                            </li>
                            <li class="index-item method">
                                <a href="#method_remove_fragment">remove_fragment</a>

                            </li>
                            <li class="index-item method">
                                <a href="#method_remove_image_by_id">remove_image_by_id</a>

                            </li>
                            <li class="index-item method">
                                <a href="#method_toggle_fragment_completed">toggle_fragment_completed</a>

                            </li>
                    </ul>
                </div>

                <div class="index-section properties">
                    <h3>Properties</h3>

                    <ul class="index-list properties">
                            <li class="index-item property private">
                                <a href="#property__driver">_driver</a>

                            </li>
                            <li class="index-item property">
                                <a href="#property__logged_in">_logged_in</a>

                            </li>
                            <li class="index-item property">
                                <a href="#property_development">development</a>

                            </li>
                    </ul>
                </div>


        </div>

            <div id="methods" class="api-class-tabpanel">
                <h2 class="off-left">Methods</h2>

<div id="method__get_driver" class="method item private">
    <h3 class="name"><code>_get_driver</code></h3>

        <span class="paren">()</span>

        <span class="returns-inline">
            <span class="type">Driver</span>
        </span>


        <span class="flag private">private</span>





    <div class="meta">
                <p>
                Defined in
        <a href="../files/src_database.js.html#l145"><code>src\database.js:145</code></a>
        </p>



    </div>

    <div class="description">
        <p>Get the database driver
stores the instance in _driver
makes use of the development flag in order to use or not use basic auth</p>

    </div>


        <div class="returns">
            <h4>Returns:</h4>

            <div class="returns-description">
                        <span class="type">Driver</span>:
                    <p>Returns a bolt:// driver instance</p>

            </div>
        </div>


</div>
<div id="method__get_session" class="method item private">
    <h3 class="name"><code>_get_session</code></h3>

        <span class="paren">()</span>

        <span class="returns-inline">
            <span class="type">Session</span>
        </span>


        <span class="flag private">private</span>





    <div class="meta">
                <p>
                Defined in
        <a href="../files/src_database.js.html#l161"><code>src\database.js:161</code></a>
        </p>



    </div>

    <div class="description">
        <p>Get a session to execute Neo4J Cypher code on</p>

    </div>


        <div class="returns">
            <h4>Returns:</h4>

            <div class="returns-description">
                        <span class="type">Session</span>:
            </div>
        </div>


</div>
<div id="method__hygiene" class="method item">
    <h3 class="name"><code>_hygiene</code></h3>

        <span class="paren">()</span>

        <span class="returns-inline">
            <span class="type">Promise</span>
        </span>







    <div class="meta">
                <p>
                Defined in
        <a href="../files/src_database.js.html#l191"><code>src\database.js:191</code></a>
        </p>



    </div>

    <div class="description">
        <p>Clean up the database on login</p>
<ol>
<li>remove nodes without edges (-&gt; MetaGroups that are not referenced)</li>
</ol>

    </div>


        <div class="returns">
            <h4>Returns:</h4>

            <div class="returns-description">
                        <span class="type">Promise</span>:
            </div>
        </div>


</div>
<div id="method__remove_constraints" class="method item private">
    <h3 class="name"><code>_remove_constraints</code></h3>

        <span class="paren">()</span>

        <span class="returns-inline">
            <span class="type">Promise</span>
        </span>


        <span class="flag private">private</span>





    <div class="meta">
                <p>
                Defined in
        <a href="../files/src_database.js.html#l205"><code>src\database.js:205</code></a>
        </p>



    </div>

    <div class="description">
        <p>Remove the constraints</p>

    </div>


        <div class="returns">
            <h4>Returns:</h4>

            <div class="returns-description">
                        <span class="type">Promise</span>:
            </div>
        </div>


</div>
<div id="method_add_comment_to_fragment" class="method item">
    <h3 class="name"><code>add_comment_to_fragment</code></h3>

        <div class="args">
            <span class="paren">(</span><ul class="args-list inline commas">
                <li class="arg">
                        <code>fragment_id</code>
                </li>
                <li class="arg">
                        <code>comment</code>
                </li>
            </ul><span class="paren">)</span>
        </div>

        <span class="returns-inline">
            <span class="type">Promise</span>
        </span>







    <div class="meta">
                <p>
                Defined in
        <a href="../files/src_database.js.html#l498"><code>src\database.js:498</code></a>
        </p>



    </div>

    <div class="description">
        <p>Sets the comment attribute of a fragment</p>

    </div>

        <div class="params">
            <h4>Parameters:</h4>

            <ul class="params-list">
                <li class="param">
                        <code class="param-name">fragment_id</code>
                        <span class="type">Object</span>


                    <div class="param-description">
                         
                    </div>

                </li>
                <li class="param">
                        <code class="param-name">comment</code>
                        <span class="type">Object</span>


                    <div class="param-description">
                        <p>string</p>

                    </div>

                </li>
            </ul>
        </div>

        <div class="returns">
            <h4>Returns:</h4>

            <div class="returns-description">
                        <span class="type">Promise</span>:
            </div>
        </div>


</div>
<div id="method_add_constraints" class="method item">
    <h3 class="name"><code>add_constraints</code></h3>

        <span class="paren">()</span>

        <span class="returns-inline">
            <span class="type">Session</span>
        </span>







    <div class="meta">
                <p>
                Defined in
        <a href="../files/src_database.js.html#l179"><code>src\database.js:179</code></a>
        </p>



    </div>

    <div class="description">
        <p>Add the necessary constraints to create something like a schema</p>
<ol>
<li>The file_path of an image is unique</li>
</ol>

    </div>


        <div class="returns">
            <h4>Returns:</h4>

            <div class="returns-description">
                        <span class="type">Session</span>:
            </div>
        </div>


</div>
<div id="method_add_edge" class="method item">
    <h3 class="name"><code>add_edge</code></h3>

        <div class="args">
            <span class="paren">(</span><ul class="args-list inline commas">
                <li class="arg">
                        <code>image_id</code>
                </li>
                <li class="arg">
                        <code>fragment_id</code>
                </li>
                <li class="arg">
                        <code>source_enum</code>
                </li>
                <li class="arg">
                        <code>target_enum</code>
                </li>
                <li class="arg">
                        <code>edge_attributes</code>
                </li>
            </ul><span class="paren">)</span>
        </div>

        <span class="returns-inline">
            <span class="type">Promise</span>
        </span>







    <div class="meta">
                <p>
                Defined in
        <a href="../files/src_database.js.html#l720"><code>src\database.js:720</code></a>
        </p>



    </div>

    <div class="description">
        <p>Adds an edge between two nodes
in a fragment of an image</p>
<p>Promise:success  number_of_created_edges</p>

    </div>

        <div class="params">
            <h4>Parameters:</h4>

            <ul class="params-list">
                <li class="param">
                        <code class="param-name">image_id</code>
                        <span class="type">Object</span>


                    <div class="param-description">
                         
                    </div>

                </li>
                <li class="param">
                        <code class="param-name">fragment_id</code>
                        <span class="type">Object</span>


                    <div class="param-description">
                         
                    </div>

                </li>
                <li class="param">
                        <code class="param-name">source_enum</code>
                        <span class="type">Object</span>


                    <div class="param-description">
                         
                    </div>

                </li>
                <li class="param">
                        <code class="param-name">target_enum</code>
                        <span class="type">Object</span>


                    <div class="param-description">
                         
                    </div>

                </li>
                <li class="param">
                        <code class="param-name">edge_attributes</code>
                        <span class="type">Object</span>


                    <div class="param-description">
                         
                    </div>

                </li>
            </ul>
        </div>

        <div class="returns">
            <h4>Returns:</h4>

            <div class="returns-description">
                        <span class="type">Promise</span>:
            </div>
        </div>


</div>
<div id="method_add_edge" class="method item">
    <h3 class="name"><code>add_edge</code></h3>

        <div class="args">
            <span class="paren">(</span><ul class="args-list inline commas">
                <li class="arg">
                        <code>node_id</code>
                </li>
                <li class="arg">
                        <code>frame_name</code>
                </li>
                <li class="arg">
                        <code>groupType</code>
                </li>
            </ul><span class="paren">)</span>
        </div>

        <span class="returns-inline">
            <span class="type">Promise</span>
        </span>







    <div class="meta">
                <p>
                Defined in
        <a href="../files/src_database.js.html#l691"><code>src\database.js:691</code></a>
        </p>



    </div>

    <div class="description">
        <p>Adds an edge between a frame from a group and a global frame
so called 'meta frame'</p>
<p>Also creates the 'meta frame' if it does not exist *</p>

    </div>

        <div class="params">
            <h4>Parameters:</h4>

            <ul class="params-list">
                <li class="param">
                        <code class="param-name">node_id</code>
                        <span class="type">Object</span>


                    <div class="param-description">
                         
                    </div>

                </li>
                <li class="param">
                        <code class="param-name">frame_name</code>
                        <span class="type">Object</span>


                    <div class="param-description">
                         
                    </div>

                </li>
                <li class="param">
                        <code class="param-name">groupType</code>
                        <span class="type">Object</span>


                    <div class="param-description">
                         
                    </div>

                </li>
            </ul>
        </div>

        <div class="returns">
            <h4>Returns:</h4>

            <div class="returns-description">
                        <span class="type">Promise</span>:
            </div>
        </div>


</div>
<div id="method_add_fragment" class="method item">
    <h3 class="name"><code>add_fragment</code></h3>

        <div class="args">
            <span class="paren">(</span><ul class="args-list inline commas">
                <li class="arg">
                        <code>image_id</code>
                </li>
                <li class="arg">
                        <code>fragment_name</code>
                </li>
            </ul><span class="paren">)</span>
        </div>

        <span class="returns-inline">
            <span class="type">Promise</span>
        </span>







    <div class="meta">
                <p>
                Defined in
        <a href="../files/src_database.js.html#l468"><code>src\database.js:468</code></a>
        </p>



    </div>

    <div class="description">
        <p>Adds a fragment to an image
Every image can have multiple fragments
the name of the fragment is unique</p>

    </div>

        <div class="params">
            <h4>Parameters:</h4>

            <ul class="params-list">
                <li class="param">
                        <code class="param-name">image_id</code>
                        <span class="type">Object</span>


                    <div class="param-description">
                         
                    </div>

                </li>
                <li class="param">
                        <code class="param-name">fragment_name</code>
                        <span class="type">Object</span>


                    <div class="param-description">
                        <p>The identifier for the fragment</p>

                    </div>

                </li>
            </ul>
        </div>

        <div class="returns">
            <h4>Returns:</h4>

            <div class="returns-description">
                        <span class="type">Promise</span>:
            </div>
        </div>


</div>
<div id="method_add_image" class="method item">
    <h3 class="name"><code>add_image</code></h3>

        <div class="args">
            <span class="paren">(</span><ul class="args-list inline commas">
                <li class="arg">
                        <code>file_path</code>
                </li>
                <li class="arg">
                        <code>exif_data</code>
                </li>
            </ul><span class="paren">)</span>
        </div>

        <span class="returns-inline">
            <span class="type">Promise</span>
        </span>







    <div class="meta">
                <p>
                Defined in
        <a href="../files/src_database.js.html#l258"><code>src\database.js:258</code></a>
        </p>



    </div>

    <div class="description">
        <p>Adds an image to the database
Sets attributes according to the exif_data
Fallback for upload_date is now in seconds (Math.round(d.getTime()))</p>
<p>The exif_data shall be an objects with the attributes
'exif: {
'ExifImageWidth': ...,
'ExifImageHeight': ...,
'CreateDate': ...
}, 'gps: {...}</p>
<p>CreateDate is handled by the parse(...) function</p>

    </div>

        <div class="params">
            <h4>Parameters:</h4>

            <ul class="params-list">
                <li class="param">
                        <code class="param-name">file_path</code>
                        <span class="type">String</span>


                    <div class="param-description">
                        <p>The unique identifier for an image</p>

                    </div>

                </li>
                <li class="param">
                        <code class="param-name">exif_data</code>
                        <span class="type">Object</span>


                    <div class="param-description">
                         
                    </div>

                </li>
            </ul>
        </div>

        <div class="returns">
            <h4>Returns:</h4>

            <div class="returns-description">
                        <span class="type">Promise</span>:
            </div>
        </div>


</div>
<div id="method_add_node" class="method item">
    <h3 class="name"><code>add_node</code></h3>

        <div class="args">
            <span class="paren">(</span><ul class="args-list inline commas">
                <li class="arg">
                        <code>image_id</code>
                </li>
                <li class="arg">
                        <code>fragment_id</code>
                </li>
                <li class="arg">
                        <code>node_label</code>
                </li>
                <li class="arg">
                        <code>node_attributes</code>
                </li>
            </ul><span class="paren">)</span>
        </div>

        <span class="returns-inline">
            <span class="type">Promise</span>
        </span>







    <div class="meta">
                <p>
                Defined in
        <a href="../files/src_database.js.html#l650"><code>src\database.js:650</code></a>
        </p>



    </div>

    <div class="description">
        <p>Adds a node to a fragment of an image</p>
<p>Promise:success  number_of_created_nodes</p>

    </div>

        <div class="params">
            <h4>Parameters:</h4>

            <ul class="params-list">
                <li class="param">
                        <code class="param-name">image_id</code>
                        <span class="type">Object</span>


                    <div class="param-description">
                         
                    </div>

                </li>
                <li class="param">
                        <code class="param-name">fragment_id</code>
                        <span class="type">Object</span>


                    <div class="param-description">
                         
                    </div>

                </li>
                <li class="param">
                        <code class="param-name">node_label</code>
                        <span class="type">Object</span>


                    <div class="param-description">
                         
                    </div>

                </li>
                <li class="param">
                        <code class="param-name">node_attributes</code>
                        <span class="type">Object</span>


                    <div class="param-description">
                         
                    </div>

                </li>
            </ul>
        </div>

        <div class="returns">
            <h4>Returns:</h4>

            <div class="returns-description">
                        <span class="type">Promise</span>:
            </div>
        </div>


</div>
<div id="method_get_all_completed_fragments" class="method item">
    <h3 class="name"><code>get_all_completed_fragments</code></h3>

        <span class="paren">()</span>

        <span class="returns-inline">
            <span class="type"> | Promise</span>
        </span>







    <div class="meta">
                <p>
                Defined in
        <a href="../files/src_database.js.html#l838"><code>src\database.js:838</code></a>
        </p>



    </div>

    <div class="description">
        <p>Get all completed fragments</p>

    </div>


        <div class="returns">
            <h4>Returns:</h4>

            <div class="returns-description">
                        <span class="type"> | Promise</span>:
            </div>
        </div>


</div>
<div id="method_get_all_fragments" class="method item">
    <h3 class="name"><code>get_all_fragments</code></h3>

        <span class="paren">()</span>

        <span class="returns-inline">
            <span class="type">Promise</span>
        </span>







    <div class="meta">
                <p>
                Defined in
        <a href="../files/src_database.js.html#l630"><code>src\database.js:630</code></a>
        </p>



    </div>

    <div class="description">
        <p>Get the fragment of an image by name</p>

    </div>


        <div class="returns">
            <h4>Returns:</h4>

            <div class="returns-description">
                        <span class="type">Promise</span>:
            </div>
        </div>


</div>
<div id="method_get_all_images" class="method item">
    <h3 class="name"><code>get_all_images</code></h3>

        <span class="paren">()</span>

        <span class="returns-inline">
            <span class="type">Promise</span>
        </span>







    <div class="meta">
                <p>
                Defined in
        <a href="../files/src_database.js.html#l755"><code>src\database.js:755</code></a>
        </p>



    </div>

    <div class="description">
        <p>Returns a promise with an array of records of images
ordered by last_edit_date, upload_date</p>

    </div>


        <div class="returns">
            <h4>Returns:</h4>

            <div class="returns-description">
                        <span class="type">Promise</span>:
            </div>
        </div>


        <div class="example">
            <h4>Example:</h4>

            <div class="example-content">
                <pre class="code prettyprint"><code>  database.get_all_images().then(function (results) {
       var row_data = [];
       results.forEach(function (r) {
           row_data.push([r.get('ident'), r.get('file_path'), r.get('upload_date'), r.get('completed')]);
       });
       res.render('table',
           {
               title: 'Hey',
               message: 'Hello there!',
               rows: row_data
           });
       }
   );</code></pre>

            </div>
        </div>
</div>
<div id="method_get_all_property_keys_for_token" class="method item">
    <h3 class="name"><code>get_all_property_keys_for_token</code></h3>

        <div class="args">
            <span class="paren">(</span><ul class="args-list inline commas">
                <li class="arg">
                        <code>search_string</code>
                </li>
                <li class="arg">
                        <code>label</code>
                </li>
                <li class="arg">
                        <code>token_type</code>
                </li>
            </ul><span class="paren">)</span>
        </div>

        <span class="returns-inline">
            <span class="type">Promise</span>
        </span>







    <div class="meta">
                <p>
                Defined in
        <a href="../files/src_database.js.html#l864"><code>src\database.js:864</code></a>
        </p>



    </div>

    <div class="description">
        <p>Returns all possible property keys for tokens filtered by search_string
Is used for the autocomplete function of the add-property-input</p>
<p>Promise:success: Array of strings</p>

    </div>

        <div class="params">
            <h4>Parameters:</h4>

            <ul class="params-list">
                <li class="param">
                        <code class="param-name">search_string</code>
                        <span class="type">String</span>


                    <div class="param-description">
                        <p>Empty string gives all possible values</p>

                    </div>

                </li>
                <li class="param">
                        <code class="param-name">label</code>
                        <span class="type">Object</span>


                    <div class="param-description">
                         
                    </div>

                </li>
                <li class="param">
                        <code class="param-name">token_type</code>
                        <span class="type">Object</span>


                    <div class="param-description">
                         
                    </div>

                </li>
            </ul>
        </div>

        <div class="returns">
            <h4>Returns:</h4>

            <div class="returns-description">
                        <span class="type">Promise</span>:
            </div>
        </div>


</div>
<div id="method_get_all_property_values_for_token" class="method item">
    <h3 class="name"><code>get_all_property_values_for_token</code></h3>

        <div class="args">
            <span class="paren">(</span><ul class="args-list inline commas">
                <li class="arg">
                        <code>property</code>
                </li>
                <li class="arg">
                        <code>search_string</code>
                </li>
            </ul><span class="paren">)</span>
        </div>

        <span class="returns-inline">
            <span class="type">Promise</span>
        </span>







    <div class="meta">
                <p>
                Defined in
        <a href="../files/src_database.js.html#l908"><code>src\database.js:908</code></a>
        </p>



    </div>

    <div class="description">
        <p>Returns all distinct values for the given property in a string list in a promise
Is used for the autocomplete function of the property values</p>
<p>Promise:success: Array of strings *</p>

    </div>

        <div class="params">
            <h4>Parameters:</h4>

            <ul class="params-list">
                <li class="param">
                        <code class="param-name">property</code>
                        <span class="type">String</span>


                    <div class="param-description">
                        <p>the name of a property of tokens</p>

                    </div>

                </li>
                <li class="param">
                        <code class="param-name">search_string</code>
                        <span class="type">String</span>


                    <div class="param-description">
                        <p>that filters the result (empty string is not filter)</p>

                    </div>

                </li>
            </ul>
        </div>

        <div class="returns">
            <h4>Returns:</h4>

            <div class="returns-description">
                        <span class="type">Promise</span>:
            </div>
        </div>


</div>
<div id="method_get_fragment" class="method item">
    <h3 class="name"><code>get_fragment</code></h3>

        <div class="args">
            <span class="paren">(</span><ul class="args-list inline commas">
                <li class="arg">
                        <code>image_file_path</code>
                </li>
                <li class="arg">
                        <code>fragment_name</code>
                </li>
            </ul><span class="paren">)</span>
        </div>

        <span class="returns-inline">
            <span class="type">Promise</span>
        </span>







    <div class="meta">
                <p>
                Defined in
        <a href="../files/src_database.js.html#l578"><code>src\database.js:578</code></a>
        </p>



    </div>

    <div class="description">
        <p>Get the fragment of an image by name</p>

    </div>

        <div class="params">
            <h4>Parameters:</h4>

            <ul class="params-list">
                <li class="param">
                        <code class="param-name">image_file_path</code>
                        <span class="type">String</span>


                    <div class="param-description">
                        <p>The unique id for the image</p>

                    </div>

                </li>
                <li class="param">
                        <code class="param-name">fragment_name</code>
                        <span class="type">Object</span>


                    <div class="param-description">
                        <p>The identifier for the fragments</p>

                    </div>

                </li>
            </ul>
        </div>

        <div class="returns">
            <h4>Returns:</h4>

            <div class="returns-description">
                        <span class="type">Promise</span>:
            </div>
        </div>


</div>
<div id="method_get_fragment_bounding_box" class="method item">
    <h3 class="name"><code>get_fragment_bounding_box</code></h3>

        <div class="args">
            <span class="paren">(</span><ul class="args-list inline commas">
                <li class="arg">
                        <code>token_id</code>
                </li>
            </ul><span class="paren">)</span>
        </div>

        <span class="returns-inline">
            <span class="type">Promise</span>
        </span>







    <div class="meta">
                <p>
                Defined in
        <a href="../files/src_database.js.html#l383"><code>src\database.js:383</code></a>
        </p>



    </div>

    <div class="description">
        <p>Get the bounding box of a fragment</p>
<p>This method looks for the lowest x and y coordinates of all sibling tokens
and for the highest x and y coordinates of all siblings</p>
<p>Used for heat map generation</p>

    </div>

        <div class="params">
            <h4>Parameters:</h4>

            <ul class="params-list">
                <li class="param">
                        <code class="param-name">token_id</code>
                        <span class="type">Int</span>


                    <div class="param-description">
                        <p>The unique identifier for a token</p>

                    </div>

                </li>
            </ul>
        </div>

        <div class="returns">
            <h4>Returns:</h4>

            <div class="returns-description">
                        <span class="type">Promise</span>:
            </div>
        </div>


</div>
<div id="method_get_fragment_by_id" class="method item">
    <h3 class="name"><code>get_fragment_by_id</code></h3>

        <div class="args">
            <span class="paren">(</span><ul class="args-list inline commas">
                <li class="arg">
                        <code>image_id</code>
                </li>
                <li class="arg">
                        <code>fragment_id</code>
                </li>
            </ul><span class="paren">)</span>
        </div>

        <span class="returns-inline">
            <span class="type">Promise</span>
        </span>







    <div class="meta">
                <p>
                Defined in
        <a href="../files/src_database.js.html#l605"><code>src\database.js:605</code></a>
        </p>



    </div>

    <div class="description">
        <p>Get the fragment of an image by name</p>

    </div>

        <div class="params">
            <h4>Parameters:</h4>

            <ul class="params-list">
                <li class="param">
                        <code class="param-name">image_id</code>
                        <span class="type">Object</span>


                    <div class="param-description">
                         
                    </div>

                </li>
                <li class="param">
                        <code class="param-name">fragment_id</code>
                        <span class="type">Object</span>


                    <div class="param-description">
                         
                    </div>

                </li>
            </ul>
        </div>

        <div class="returns">
            <h4>Returns:</h4>

            <div class="returns-description">
                        <span class="type">Promise</span>:
            </div>
        </div>


</div>
<div id="method_get_fragments_by_image_id" class="method item">
    <h3 class="name"><code>get_fragments_by_image_id</code></h3>

        <div class="args">
            <span class="paren">(</span><ul class="args-list inline commas">
                <li class="arg">
                        <code>image_id</code>
                </li>
            </ul><span class="paren">)</span>
        </div>

        <span class="returns-inline">
            <span class="type"> | Promise</span>
        </span>







    <div class="meta">
                <p>
                Defined in
        <a href="../files/src_database.js.html#l803"><code>src\database.js:803</code></a>
        </p>



    </div>

    <div class="description">
        <p>Get all fragments of one image</p>

    </div>

        <div class="params">
            <h4>Parameters:</h4>

            <ul class="params-list">
                <li class="param">
                        <code class="param-name">image_id</code>
                        <span class="type">Object</span>


                    <div class="param-description">
                         
                    </div>

                </li>
            </ul>
        </div>

        <div class="returns">
            <h4>Returns:</h4>

            <div class="returns-description">
                        <span class="type"> | Promise</span>:
            </div>
        </div>


</div>
<div id="method_get_image" class="method item">
    <h3 class="name"><code>get_image</code></h3>

        <div class="args">
            <span class="paren">(</span><ul class="args-list inline commas">
                <li class="arg">
                        <code>file_path</code>
                </li>
            </ul><span class="paren">)</span>
        </div>

        <span class="returns-inline">
            <span class="type">Promise</span>
        </span>







    <div class="meta">
                <p>
                Defined in
        <a href="../files/src_database.js.html#l335"><code>src\database.js:335</code></a>
        </p>



    </div>

    <div class="description">
        <p>Get image from database by file_path</p>
<p>Promise: success: Contains record for the image</p>

    </div>

        <div class="params">
            <h4>Parameters:</h4>

            <ul class="params-list">
                <li class="param">
                        <code class="param-name">file_path</code>
                        <span class="type">String</span>


                    <div class="param-description">
                        <p>The unique identifier for an image</p>

                    </div>

                </li>
            </ul>
        </div>

        <div class="returns">
            <h4>Returns:</h4>

            <div class="returns-description">
                        <span class="type">Promise</span>:
            </div>
        </div>


</div>
<div id="method_get_image_of_token" class="method item">
    <h3 class="name"><code>get_image_of_token</code></h3>

        <div class="args">
            <span class="paren">(</span><ul class="args-list inline commas">
                <li class="arg">
                        <code>token_id</code>
                </li>
            </ul><span class="paren">)</span>
        </div>

        <span class="returns-inline">
            <span class="type">Promise</span>
        </span>







    <div class="meta">
                <p>
                Defined in
        <a href="../files/src_database.js.html#l360"><code>src\database.js:360</code></a>
        </p>



    </div>

    <div class="description">
        <p>Get the image of a token</p>

    </div>

        <div class="params">
            <h4>Parameters:</h4>

            <ul class="params-list">
                <li class="param">
                        <code class="param-name">token_id</code>
                        <span class="type">Int</span>


                    <div class="param-description">
                        <p>The unique identifier for a token</p>

                    </div>

                </li>
            </ul>
        </div>

        <div class="returns">
            <h4>Returns:</h4>

            <div class="returns-description">
                        <span class="type">Promise</span>:
            </div>
        </div>


</div>
<div id="method_init" class="method item">
    <h3 class="name"><code>init</code></h3>

        <span class="paren">()</span>

        <span class="returns-inline">
            <span class="type">Session</span>
        </span>







    <div class="meta">
                <p>
                Defined in
        <a href="../files/src_database.js.html#l217"><code>src\database.js:217</code></a>
        </p>



    </div>

    <div class="description">
        <p>Do the initialization on start</p>
<ol>
<li>drop and then create constraint</li>
</ol>

    </div>


        <div class="returns">
            <h4>Returns:</h4>

            <div class="returns-description">
                        <span class="type">Session</span>:
            </div>
        </div>


</div>
<div id="method_log_error_and_close_session" class="method item">
    <h3 class="name"><code>log_error_and_close_session</code></h3>

        <span class="paren">()</span>

        <span class="returns-inline">
            <span class="type">Error</span>
        </span>







    <div class="meta">
                <p>
                Defined in
        <a href="../files/src_database.js.html#l136"><code>src\database.js:136</code></a>
        </p>



    </div>

    <div class="description">
        <p>Generic catch error function for database promises
Logs the error and closes the db session</p>

    </div>


        <div class="returns">
            <h4>Returns:</h4>

            <div class="returns-description">
                        <span class="type">Error</span>:
            </div>
        </div>


</div>
<div id="method_login" class="method item">
    <h3 class="name"><code>login</code></h3>

        <div class="args">
            <span class="paren">(</span><ul class="args-list inline commas">
                <li class="arg">
                        <code>url</code>
                </li>
                <li class="arg">
                        <code>user</code>
                </li>
                <li class="arg">
                        <code>password</code>
                </li>
            </ul><span class="paren">)</span>
        </div>

        <span class="returns-inline">
            <span class="type">Boolean | Error</span>
        </span>







    <div class="meta">
                <p>
                Defined in
        <a href="../files/src_database.js.html#l55"><code>src\database.js:55</code></a>
        </p>



    </div>

    <div class="description">
        <p>Try to fetch a neo4j driver with the given credentials
if that works, the Database._driver is not null anymore.
It also set the Database.logged_in to true</p>

    </div>

        <div class="params">
            <h4>Parameters:</h4>

            <ul class="params-list">
                <li class="param">
                        <code class="param-name">url</code>
                        <span class="type">String</span>


                    <div class="param-description">
                        <p>the endpoint of neo4j</p>

                    </div>

                </li>
                <li class="param">
                        <code class="param-name">user</code>
                        <span class="type">String</span>


                    <div class="param-description">
                         
                    </div>

                </li>
                <li class="param">
                        <code class="param-name">password</code>
                        <span class="type">String</span>


                    <div class="param-description">
                         
                    </div>

                </li>
            </ul>
        </div>

        <div class="returns">
            <h4>Returns:</h4>

            <div class="returns-description">
                        <span class="type">Boolean | Error</span>:
            </div>
        </div>


</div>
<div id="method_logout" class="method item">
    <h3 class="name"><code>logout</code></h3>

        <span class="paren">()</span>

        <span class="returns-inline">
            <span class="type">Boolean</span>
        </span>







    <div class="meta">
                <p>
                Defined in
        <a href="../files/src_database.js.html#l119"><code>src\database.js:119</code></a>
        </p>



    </div>

    <div class="description">
        <p>Logout from the current database neo4j session.
Delete the saved neo4j session and set the Database.logged_in flag to false.</p>

    </div>


        <div class="returns">
            <h4>Returns:</h4>

            <div class="returns-description">
                        <span class="type">Boolean</span>:
            </div>
        </div>


</div>
<div id="method_remove_fragment" class="method item">
    <h3 class="name"><code>remove_fragment</code></h3>

        <div class="args">
            <span class="paren">(</span><ul class="args-list inline commas">
                <li class="arg">
                        <code>image_id</code>
                </li>
                <li class="arg">
                        <code>fragment_id</code>
                </li>
                <li class="arg">
                        <code>dont_delete_fragment</code>
                </li>
            </ul><span class="paren">)</span>
        </div>

        <span class="returns-inline">
            <span class="type">Promise</span>
        </span>







    <div class="meta">
                <p>
                Defined in
        <a href="../files/src_database.js.html#l528"><code>src\database.js:528</code></a>
        </p>



    </div>

    <div class="description">
        <p>Removes a fragment of an image or makes it empty</p>
<p>This method not only deletes the fragment but also its children</p>

    </div>

        <div class="params">
            <h4>Parameters:</h4>

            <ul class="params-list">
                <li class="param">
                        <code class="param-name">image_id</code>
                        <span class="type">Object</span>


                    <div class="param-description">
                         
                    </div>

                </li>
                <li class="param">
                        <code class="param-name">fragment_id</code>
                        <span class="type">Object</span>


                    <div class="param-description">
                         
                    </div>

                </li>
                <li class="param">
                        <code class="param-name">dont_delete_fragment</code>
                        <span class="type">Object</span>


                    <div class="param-description">
                        <p>Activate this option to delete only the children</p>

                    </div>

                </li>
            </ul>
        </div>

        <div class="returns">
            <h4>Returns:</h4>

            <div class="returns-description">
                        <span class="type">Promise</span>:
            </div>
        </div>


</div>
<div id="method_remove_image_by_id" class="method item">
    <h3 class="name"><code>remove_image_by_id</code></h3>

        <div class="args">
            <span class="paren">(</span><ul class="args-list inline commas">
                <li class="arg">
                        <code>id_</code>
                </li>
            </ul><span class="paren">)</span>
        </div>

        <span class="returns-inline">
            <span class="type">Promise</span>
        </span>







    <div class="meta">
                <p>
                Defined in
        <a href="../files/src_database.js.html#l420"><code>src\database.js:420</code></a>
        </p>



    </div>

    <div class="description">
        <p>Removes an image by ID</p>

    </div>

        <div class="params">
            <h4>Parameters:</h4>

            <ul class="params-list">
                <li class="param">
                        <code class="param-name">id_</code>
                        <span class="type">String | Number</span>


                    <div class="param-description">
                         
                    </div>

                </li>
            </ul>
        </div>

        <div class="returns">
            <h4>Returns:</h4>

            <div class="returns-description">
                        <span class="type">Promise</span>:
            </div>
        </div>


</div>
<div id="method_toggle_fragment_completed" class="method item">
    <h3 class="name"><code>toggle_fragment_completed</code></h3>

        <span class="paren">()</span>

        <span class="returns-inline">
            <span class="type">Promise</span>
        </span>







    <div class="meta">
                <p>
                Defined in
        <a href="../files/src_database.js.html#l232"><code>src\database.js:232</code></a>
        </p>



    </div>

    <div class="description">
        <p>Toggle the completed status of a fragment
The status is used for the batch-add functionality</p>

    </div>


        <div class="returns">
            <h4>Returns:</h4>

            <div class="returns-description">
                        <span class="type">Promise</span>:
            </div>
        </div>


</div>
            </div>

            <div id="properties" class="api-class-tabpanel">
                <h2 class="off-left">Properties</h2>

<div id="property__driver" class="property item private">
    <h3 class="name"><code>_driver</code></h3>
    <span class="type">Driver</span>


        <span class="flag private">private</span>



    <div class="meta">
                <p>
                Defined in
        <a href="../files/src_database.js.html#l36"><code>src\database.js:36</code></a>
        </p>


    </div>

    <div class="description">
        <p>Stores the neo4j-driver for the method &lt;_get_driver&gt;</p>

    </div>

        <p><strong>Default:</strong> null</p>


</div>
<div id="property__logged_in" class="property item">
    <h3 class="name"><code>_logged_in</code></h3>
    <span class="type">Boolean</span>





    <div class="meta">
                <p>
                Defined in
        <a href="../files/src_database.js.html#l46"><code>src\database.js:46</code></a>
        </p>


    </div>

    <div class="description">
        <p>Stores whether a successful login took place</p>

    </div>

        <p><strong>Default:</strong> false</p>


</div>
<div id="property_development" class="property item">
    <h3 class="name"><code>development</code></h3>
    <span class="type">Boolean</span>





    <div class="meta">
                <p>
                Defined in
        <a href="../files/src_database.js.html#l27"><code>src\database.js:27</code></a>
        </p>


    </div>

    <div class="description">
        <p>The development flag controls the basic auth credentials</p>

    </div>

        <p><strong>Default:</strong> false</p>


</div>
            </div>


    </div>
</div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="../assets/vendor/prettify/prettify-min.js"></script>
<script>prettyPrint();</script>
<script src="../assets/js/yui-prettify.js"></script>
<script src="../assets/../api.js"></script>
<script src="../assets/js/api-filter.js"></script>
<script src="../assets/js/api-list.js"></script>
<script src="../assets/js/api-search.js"></script>
<script src="../assets/js/apidocs.js"></script>
</body>
</html>
